﻿//========================================
// All rights reserved (C) 2017-2100
// CLR 版本：	4.0.30319.42000
// 命名空间:	SFJDService.SocketHandle
// 文 件 名：	PH01SynDataCheckSe
// 作    者：	WooG
// 联系方式：	wooglle@163.com
// 创建时间：	2018/3/12 16:42:07
//========================================
using Common;
using Network.UpdateData;
using System;
using System.Net.Sockets;
using System.Threading;

namespace SFJDService.SocketHandle
{
    /// <summary>
    /// 同步数据模式下，根据收到的数字，对数字以后的数据进行广播
    /// </summary>
    public class PH01SynDataCheckSe : PacketHandle
    {
        /// <summary>
        /// UDP
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="packet"></param>
        public PH01SynDataCheckSe(Socket socket, Packet packet) : base(socket, packet)
        {
        }

        protected override void Handle()
        {
            int start = int.Parse(Message);
            int end = Runtime.xmlData.GetLastID();
            if(end >= start)
            {
                for(int i = start; i <= end; i++)
                {
                    ClassData data = Runtime.xmlData.GetDataByID(DateTime.Today.Year.ToString(), i);
                    Launcher.SendMsg2All(typeof(PH01SynDataCheckRe).GetDictianaryKey(), data.CodingToString());
                    Thread.Sleep(100);
                }
            }
        }
    }
}